package com.cv.platform.controller.platform.subscribe;

import com.cv.framework.common.pojo.PageResult;
import com.cv.framework.common.pojo.Result;
import com.cv.platform.controller.platform.subscribe.vo.*;
import com.cv.platform.service.subscribe.CvSubscribeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;

/**
 * 视频平台 - 用户订阅控制层
 *
 * @author Charles_XDXD
 */
@Tag(name = "视频平台 - 用户订阅控制层")
@RestController
@RequestMapping("/platform/subscribe")
public class CvSubscribeController {

    @Resource
    private CvSubscribeService cvSubscribeService;

    @GetMapping("get")
    @Operation(summary = "获取用户订阅信息")
    public Result<CvSubscribeDetailRespVO> getSubscribe(Long targetId) {
        return Result.success(cvSubscribeService.getSubscribe(targetId));
    }

    @PostMapping("save")
    @Operation(summary = "保存用户订阅")
    public Result<Void> saveSubscribe(@RequestBody CvSubscribeSaveReqVO reqVO) {
        cvSubscribeService.saveSubscribe(reqVO);
        return Result.success();
    }

    @DeleteMapping("delete")
    @Operation(summary = "删除用户订阅")
    public Result<Void> deleteSubscribe(Long id) {
        cvSubscribeService.deleteSubscribe(id);
        return Result.success();
    }
    
    @DeleteMapping("deleteByUserId")
    @Operation(summary = "删除用户订阅")
    public Result<Void> deleteSubscribeByUserId(Long targetId) {
        cvSubscribeService.deleteSubscribeByUserId(targetId);
        return Result.success();
    }

    @GetMapping("page")
    @Operation(summary = "用户订阅分页数据")
    public Result<PageResult<CvSubscribeRespVO>> getSubscribePage(CvSubscribeReqVO reqVO) {
        return Result.success(cvSubscribeService.selectSubscribePage(reqVO));
    }

    @GetMapping("fansPage")
    @Operation(summary = "用户粉丝分页数据")
    @PermitAll
    public Result<PageResult<CvSubscribePageRespVO>> getFansPage(CvSubscribePageReqVO reqVO) {
        return Result.success(cvSubscribeService.getFansPage(reqVO));
    }

    @GetMapping("followPage")
    @Operation(summary = "用户关注分页数据")
    @PermitAll
    public Result<PageResult<CvSubscribePageRespVO>> getFollowPage(CvSubscribePageReqVO reqVO) {
        return Result.success(cvSubscribeService.getFollowPage(reqVO));
    }

}
